package com.gitee.cashzhang27.test.cloud.webflux.hello.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Random;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Cash Zhang
 * @version v1.0
 * @since 2019/11/19 13:28
 */
@Slf4j
@RestController
public class HelloController {

  @GetMapping("/greeting")
  public String greet() {
    log.info("Access /greeting");

    List<String> greetings = Arrays.asList("Hi there", "Greetings", "Salutations");
    Random rand = new Random();

    int randomNum = rand.nextInt(greetings.size());
    return greetings.get(randomNum);
  }

  @GetMapping("/")
  public String home() {
    log.info("Access /");
    return "Hi!";
  }

}
